package model;

import java.util.Date;

public class ModelBase
{

	private Long id;
	private Date timeStamp;

	public void setID(Long id)
	{
		this.id = id;
	}

	public Long getId()
	{
		return id;
	}

	public void setTimeStamp(Date timeStamp)
	{
		this.timeStamp = (Date) timeStamp.clone();
	}

	public Date getTimeStamp()
	{
		return (Date) timeStamp.clone();
	}
	
	public boolean isNew()
	{
		return id == null;
	}

	@Override
	public int hashCode()
	{
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		result = prime * result + ((timeStamp == null) ? 0 : timeStamp.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj)
	{
		if (this == obj) return true;
		if (obj == null) return false;
		if (getClass() != obj.getClass()) return false;
		ModelBase other = (ModelBase) obj;
		if (id == null)
		{
			if (other.id != null) return false;
		} else if (!id.equals(other.id)) return false;
		if (timeStamp == null)
		{
			if (other.timeStamp != null) return false;
		} else if (!timeStamp.equals(other.timeStamp)) return false;
		return true;
	}

}
